<extend name="Layout:base"/>

<block name="title">添加学生</block>
<block name="css">

</block>
<block name="xtyhgl">active</block>
<block name="xsgl">active</block>
<block name="menu">
    <h5 class="breadcrumbs-title">添加学生</h5>
    <ol class="breadcrumbs">
        <li class="active"><a href="{:U('Admin/Index/index')}">首页</a>
        </li>
        <li class="active">添加学生
        </li>
    </ol>
</block>

<block name="main">
    <div class="col s10 m10 l10 offset-l1 offset-s1 offset-m1">
        <h3 class="center-align">添加学生</h3>
        <form action="" method="post">
            <div class="row">
                <div class="input-field col s12">
                    <input id="stuid" name="stuid" type="text" class="validate">
                    <label for="stuid">学号</label>
                </div>
            </div>

            <div class="row">
                <div class="input-field col s12">
                    <input id="password" name="password" type="text" class="validate">
                    <label for="password">密码</label>
                </div>
            </div>

            <div class="row">
                <div class="input-field col s12">
                    <input id="name" name="name" type="text" class="validate">
                    <label for="name">学生姓名</label>
                </div>
            </div>
            <br>
            <div class="row">
                <div class="col s6 l6 m6 center-align">
                    <input class="with-gap" name="sex" value="0" type="radio" id="class0"/>
                    <label for="class0">男生</label>
                </div>
                <div class="col s6 l6 m6 center-align">
                    <input class="with-gap" name="enclass" value="1" type="radio" id="class1"/>
                    <label for="class1">女生</label>
                </div>
            </div>
            <br>
            <div class="row">
                <div class="input-field col s12">
                    <select id="dept" name="deptid" required>
                        <option value="" disabled selected>选择系部</option>
                        <volist name=":getDept()" id="vo">
                            <option value="{$vo.did}">{$vo.name}</option>
                        </volist>
                    </select>
                    <label>系部</label>
                </div>
            </div>

            <div class="row">
                <div class="input-field col s12">
                    <select id="class">
                        <option value="" disabled selected>选择班级</option>
                    </select>
                    <label>班级</label>
                </div>
            </div>

            <div class="row">
                <div class="input-field col s12 l12 m12 center-align">
                    <input class="waves-effect waves-light btn blue" type="submit" value="添加">
                    <input class="waves-effect waves-light btn red" type="reset" value="重置">
                </div>
            </div>
        </form>
    </div>

</block>

<block name="js">
    <script>
        $(document).ready(function () {
            $('select').material_select();
            $("#dept").bind({
                change: function () {
                    var deptid = $("#dept").val();
                    var url = "{:U('Admin/UserMag/retClassName')}";
                    $.post(
                            url,
                            {deptid: deptid},
                            function (data) {
                                $html = '<option value="" disabled selected>选择班级</option>';
                                $.each(data, function (index) {
                                    $html += '<option value="' + data[index].cid + '">' + data[index].name + '</option>';
                                });
                                $("#class").empty();
                                $("#class").append($html);
                                $('select').material_select();
                            }, 'json');
                }
            });
        });
    </script>
</block>